//
//  StoreIntroduceConnectsHeaderView.m
//  GLGW_Shoping
//
//  Created by whx on 2018/12/27.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "StoreIntroduceConnectsHeaderView.h"

@implementation StoreIntroduceConnectsHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        GLGWLabel *mainLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:self.contentView];
        mainLabel.text = @"联系信息";
        [mainLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.bottom.equalTo(self.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(3));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15)).priorityMedium();
        }];
        
        GLGWView *topV = [[GLGWView alloc] initWithInSuperView:self.contentView];
        topV.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
        [topV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(mainLabel.mas_top).offset(-kHeightProportion_In_iPhoneTriploid(20));
            make.left.right.equalTo(self.contentView);
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(10)));
        }];
        
        GLGWButton *topBtn = [[GLGWButton alloc] initWithTitle:@"展开全部" titleLableFont:SYSTEMFONT(12) titleLableColor:[UIColor colorWithHexString:@"#999999"] inSuperView:self.contentView];
        [topBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(topV.mas_top).offset(-kHeightProportion_In_iPhoneTriploid(20));
            make.right.equalTo(@(-kWidthProportion_In_iPhoneTriploid(15)));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(70)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        topBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        [topBtn setImage:[UIImage imageNamed:@"icon_zhankaiquanbu"] forState:UIControlStateNormal];
        [topBtn setImagePositionWithType:SSImagePositionTypeLeft spacing:5];
        topBtn.hidden = YES;
        [topBtn addTarget:self action:@selector(topAction:) forControlEvents:UIControlEventTouchUpInside];
        if (self.accountType == AccountType_FreeManagers) {
            topBtn.hidden = NO;
        }
    }
    return self;
}

- (void)topAction:(GLGWButton *)sender
{
    sender.selected = !sender.selected;
    if (self.BlockOpenAll) {
        self.BlockOpenAll(sender);
    }
}

@end
